package com.jnu.hc.jnuhcusercms.service;

import com.jnu.hc.jnuhcusercms.domain.Cireport;
import com.jnu.hc.jnuhcusercms.dto.ReportResponseDto;
import com.jnu.hc.jnuhcusercms.dto.ResponseObject;
import com.jnu.hc.jnuhcusercms.mapper.CidetailedreportMapper;
import com.jnu.hc.jnuhcusercms.mapper.CireportMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReportServiceImpl implements ReportService {
    @Autowired
    CireportMapper cireportMapper;
    @Autowired
    CidetailedreportMapper cidetailedreportMapper;
    @Override
    public ResponseObject dreport(Integer orderId){
        ReportResponseDto reportResponseDto = new ReportResponseDto();
        reportResponseDto.setCireportList(cireportMapper.selectByOrderId(orderId));
        reportResponseDto.setCidetailedreportList(cidetailedreportMapper.selectByOrderId(orderId));
        if(reportResponseDto.getCireportList().isEmpty()||reportResponseDto.getCidetailedreportList().isEmpty()){
            return new ResponseObject(404,"没有对应订单的数据");
        }
        return new ResponseObject(200,"成功",reportResponseDto);
    }
}
